package com.bigdata.movieticketapi.controller;

import com.bigdata.movieticketapi.common.pojo.PageResult;
import com.bigdata.movieticketapi.service.IUserService;
import com.bigdata.movieticketapi.vo.req.*;
import com.bigdata.movieticketapi.vo.resp.GetUserInfoRespVO;
import com.bigdata.movieticketapi.vo.resp.LoginOrRegRespVO;
import com.bigdata.movieticketapi.vo.resp.PageUniAppUserRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 小程序用户表 前端控制器
 * </p>
 *
 * @author movie
 * @since 2023-11-12
 */
@RestController
@RequestMapping("/api")
@Api(tags = "小程序用户模块")
public class UserController {

    @Resource
    private IUserService iUserService;

    @PostMapping("/uniApp/user/loginOrReg")
    @ApiOperation(value = "小程序端登录或注册接口")
    public LoginOrRegRespVO loginOrReg(@RequestBody @Valid LoginOrRegReqVO vo){
        return iUserService.loginOrReg(vo);
    }

    @PostMapping("/admin/user/edit")
    @ApiOperation(value = "小程序端用户信息更新接口")
    public void updateUserInfo(@RequestBody @Valid UpdateUserInfoReqVO vo){
        iUserService.updateUserInfo(vo);
    }

    @PostMapping("/admin/user/update")
    @ApiOperation(value = "后台用户信息更新接口")
    public void adminUpdateUserInfo(@RequestBody @Valid AdminUpdateUserInfoReqVO vo){
        iUserService.adminUpdateUserInfo(vo);
    }

    @PostMapping("/admin/user/info")
    @ApiOperation(value = "获取用户信息接口")
    public GetUserInfoRespVO getUserInfo(@RequestBody @Valid GetUserInfoReqVO vo){
        return iUserService.getUserInfo(vo);
    }

    @PostMapping("/admin/uniAppUser")
    @ApiOperation(value = "获取用户信息接口")
    public PageResult<PageUniAppUserRespVO> pageUniAppUser(@RequestBody @Valid PageUniAppUserReqVO vo){
        return iUserService.pageUniAppUser(vo);
    }

}
